﻿
@{
	ViewBag.Title = "ApplicationFallbackIndex";
	Layout = "~/Views/Shared/_Index.cshtml";
	var opr = Newtouch.Common.Operator.OperatorProvider.GetCurrent();
}

<form name="form1">
	<div class="panel panel-default">
		<table class="form">
			<tr>
				<th class="formTitle" id="thCZRQ">结算日期：</th>
				<td class="formValue" colspan="2">
					<input id="ksrq" type="text" class="form-control input-wdatepicker formClearIgnore" style="width:20%; float:left;" value="@DateTime.Now.ToString("yyyy-MM-01")" onfocus="WdatePicker({ dateFmt: 'yyyy-MM-dd' })" />
					<span style="margin-left:2%;float:left;">—</span>
					<input id="jsrq" type="text" class="form-control input-wdatepicker formClearIgnore" style="width :20%;float:left;margin-left:2%;" value="@DateTime.Now.ToString("yyyy-MM-dd")" onfocus="WdatePicker({ dateFmt: 'yyyy-MM-dd' })" />
					<text style="margin-left:2%;color:cornflowerblue">提示：按清算日期统计!</text>
					<input type="button" id="btn_search_cx" class="btn btn-primary btn-md" style="margin-left:10px;width:40px;" value="查询" />
					<input type="button" id="btn_search_td" class="btn btn-primary btn-md" style="margin-left:10px;width:50px;" value="清算撤销" />
					@*<input type="button" id="btn_search_gb" class="btn btn-primary btn-md" style="margin-left:10px;width:60px;" value="关闭" />*@
				</td>
				<td class="formValue"></td>
			</tr>
		</table>
	</div>
	<div style="background-color: #fff;">
		<table id="gridJSList"></table>
	</div>
	<div style="background-color: #fff; margin-top:5px;">
		<table id="gridJSMXList"></table>
	</div>
	<div class="gridPanel">
		<table id="gridJSList"></table>
		<div id="gridPager"></div>
	</div>


</form>

<script>
    $(function () {
        //浏览器窗口调整大小时重新加载jqGrid的宽
        $(window).resize(function () {
            initLayout("MyTabGrid");
        });

        //结算主记录
        gridJSListData();
    });

    function gridJSListData() {
        var gridSort = 'CreateTime asc';
        var $gridJsList = $("#gridJSList");
        $gridJsList.dataGrid({
            //postData: getSearchPostData(),
            height: 500,
            url: "",
            colModel: [
                { label: '清算期号', name: 'qsqh', width: 100, align: 'left' },
                { label: '清算类别', name: 'qslb', width: 100, align: 'left' },
                { label: '清算类别名称', name: 'qslbmc', width: 100, align: 'left' },
                { label: '险种类型', name: 'xzlx', width: 100, align: 'left' },
                { label: '是否异地', name: 'sfyd', width: 100, align: 'left' },
                { label: '清算流水号', name: 'qslsh', width: 100, align: 'left' },
                { label: '总费用', name: 'zfy', width: 100, align: 'left' },
                { label: '基金申报总额', name: 'jjsbze', width: 100, align: 'left' },
                { label: '个账支付总额', name: 'gzzfze', width: 100, align: 'left' },
                { label: '个人现金支付总额', name: 'grxjzfze', width: 100, align: 'left' },
                { label: '清算人次', name: 'qsrc', width: 100, align: 'left' },
                { label: '开始日期', name: 'ksrq', width: 100, align: 'left' },
                { label: '结束如期', name: 'jsrq', width: 100, align: 'left' },
                { label: '清算申请日期', name: 'qssqrq', width: 100, align: 'left' },
                { label: '清算申请人', name: 'qssqr', width: 100, align: 'left' },
                { label: '医疗机构代码', name: 'yljgdm', width: 100, align: 'left' },
                { label: '医疗机构名称', name: 'yljgmc', width: 100, align: 'left' },
                { label: '清算经办机构名称', name: 'qsjbjgmc', width: 100, align: 'left' },
                { label: '清算经办机构编码', name: 'qsjbjgbm', width: 100, align: 'left' },
                { label: '门诊人次', name: 'mzrc', width: 100, align: 'left' },
                { label: '住院人次', name: 'zyrc', width: 100, align: 'left' },
                { label: '门诊总费用', name: 'mzzfy', width: 100, align: 'left' },
                { label: '住院总费用', name: 'zyzfy', width: 100, align: 'left' },
                { label: '门诊申报金额', name: 'mzsbje', width: 100, align: 'left' },
                { label: '住院申报金额', name: 'zysbje', width: 100, align: 'left' },
				{ label: '城镇职工基本医疗保险统筹基金', name: 'czzgtcjj',   align: 'left' },
				{ label: '城镇职工基本医疗保险统筹基金人次', name: 'czzgtcjjrc',   align: 'left' },
				{ label: '城镇职工基本医疗保险个人账户基金', name: 'czzgzhjj',   align: 'left' },
				{ label: '城镇职工基本医疗保险个人账户基金人次', name: 'czzgzhjjrc',   align: 'left' },
				{ label: '公务员医疗补助基金', name: 'gywbzjj',   align: 'left' },
				{ label: '公务员医疗补助基金人次', name: 'gywbzjjrc',   align: 'left' },
				{ label: '大额医疗费用补助基金', name: 'deylbzjj',   align: 'left' },
				{ label: '大额医疗费用补助基金人次', name: 'deylbzjjrc',   align: 'left' },
				{ label: '离休人员医疗保障基金', name: 'lxrybzjj',   align: 'left' },
				{ label: '离休人员医疗保障基金人次', name: 'lxrybzjjrc',   align: 'left' },
				{ label: '一至六级残疾军人医疗补助基金', name: 'cjbzjj',   align: 'left' },
				{ label: '一至六级残疾军人医疗补助基金人次', name: 'cjbzjjrc',   align: 'left' },
				{ label: '企业补充医疗保险基金', name: 'qybzyljj',   align: 'left' },
				{ label: '企业补充医疗保险基金人次', name: 'qybzyljjrc',   align: 'left' },
				{ label: '城乡居民基本医疗保险基金', name: 'cxjmjbyljj',   align: 'left' },
				{ label: '城乡居民基本医疗保险基金人次', name: 'cxjmjbyljjrc',   align: 'left' },
				{ label: '城乡居民大病医疗保险基金', name: 'cxjmdbyljj',   align: 'left' },
				{ label: '城乡居民大病医疗保险基金人次', name: 'cxjmdbyljjrc',   align: 'left' },
				{ label: '优抚基金', name: 'yfjj',   align: 'left' },
				{ label: '优抚基金人次', name: 'yfjjrc',   align: 'left' },
				{ label: '生育基金', name: 'syjj',   align: 'left' },
				{ label: '生育基金人次', name: 'syjjrc',   align: 'left' },
				{ label: '其他基金', name: 'qtjj',   align: 'left' },
				{ label: '其他基金人次', name: 'qtjjrc',   align: 'left' },
				{ label: '二乙基金', name: 'eyjj',   align: 'left' },
				{ label: '二乙基金人次', name: 'eyjjrc',   align: 'left' },
                { label: '各项基金总和', name: 'gxjjzh', width: 100, align: 'left' },
            ],
            //pager: "#gridPager",
            //sortname: gridSort,
            viewrecords: true,
            onSelectRow_page: function (rowid) {
                console.log(rowid);
            },
            gridComplete: function (gridJszbList) {
                //jszbList = null;
                //if (gridJszbList && gridJszbList.rows) {
                //    jszbList = gridJszbList.rows;
                //}
            }
        });

        //查询事件
        $("#btn_search_cx").click(function () {
			$('#gridJSList').jqGrid("clearGridData");//先清空明细
            $gridJsList.jqGrid('setGridParam', {
                postData: { ksrq: $("#ksrq").val(), jsrq: $("#jsrq").val() },
                url: '/MedicalInsuranceLiquidation/LiquidationApplication/GetQsht',
                //page: 1,
            }).trigger('reloadGrid');
        });
	}


	$("#btn_search_td").click(function() {
		var seleRowid = $("#gridJSList").jqGrid("getGridParam", "selrow");
		if (!(seleRowid)) {
			$.modalAlert("请选中一条信息", 'warning');
			return;
		}

		var rowData = $("#gridJSList").jqGrid('getRowData', seleRowid);
		var ksrq = $("#ksrq").val();
		var jsrq = $("#jsrq").val();

		var predata = {
			hisId: "0",
			operatorId: '@(opr.rygh)',
			operatorName:'@(opr.UserName)',
			clr_type: rowData.qslb,
			clr_way: "",
			setlym: 0,
			psntime: "",
			medfee_sumamt: 0 ,
			med_sumfee: 0,
			fund_appy_sum: 0,
			cash_payamt: 0,
			acct_pay: 0,
			begndate: ksrq,
			enddate: jsrq,
			sfyd: "",
			clr_appy_evt_id: rowData.qslsh
		};

		$.ajax({
			type: "POST",
			url: "http://127.0.0.1:33333/api/YiBao/ReconciliationDetail_3204",
			data: predata,
			dataType: "json",
			async: false,
			success: function (data) {
				var refinfo = eval('(' + data + ')');
				console.log(refinfo);
				if (refinfo.infcode == "0") {
					$.modalAlert("退单成功！".err_msg, 'warning');
					$("#btn_search_cx").click();
				} else {
					$.modalAlert(refinfo.err_msg, 'warning');
				}

			}
		});
	});

</script>